export const types = {
    SET_CUR_TAB: "app/SET_CUR_TAB",
    UPDATE_CLIENT_SIZE: "app/UPDATE_CLIENT_SIZE",
    UPDATE_HANGUP_REASON: "app/UPDATE_HANGUP_REASON",
    SET_TICKET_ID: "user/SET_TICKET_ID",
};
export default {
    namespaced: true,
    state: {
        curTab: 0,
        clientHeight: document.documentElement.clientHeight,
        clientWidth: document.documentElement.clientWidth,
        isLandscape:
            document.documentElement.clientWidth >
            document.documentElement.clientHeight,
        hangupReason: "undefined",
        ticketId: "",
    },
    mutations: {
        [types.SET_CUR_TAB](state, tab) {
            state.curTab = tab;
        },
        [types.UPDATE_CLIENT_SIZE](state, size) {
            state.clientHeight = size.height;
            state.clientWidth = size.width;
            state.isLandscape = size.width > size.height;
        },
        [types.UPDATE_HANGUP_REASON](state, reason) {
            state.hangupReason = reason;
        },
        [types.SET_TICKET_ID](state, ticketId) {
            state.ticketId = ticketId;
        },
    },
    actions: {
        setCurTab({ commit }, tab) {
            commit(types.SET_CUR_TAB, tab);
        },
        updateClientSize({ commit }, size) {
            commit(types.UPDATE_CLIENT_SIZE, size);
        },
        updateHangupReason({ commit }, reason) {
            commit(types.UPDATE_HANGUP_REASON, reason);
        },
        setTicketId({ commit }, id) {
            commit(types.SET_TICKET_ID, id);
        },
    },
};
